/*
Mass_GI_Update_Controller
Description: Controller class for Mass_GI_Upadate VF page. It functionality for filtering, searching and saving 
			 Global_Input__c records.
Version 1.0
Author: Pratibh Prakash
Created Date: 15 Jul-2009			 
*/
public class Mass_GI_Update_Controller {
	public class GlobalInputs{
    	private Boolean CheckBox;
    	private Global_Input__c GI;
    	
    	public Boolean getCheckBox(){
			return this.CheckBox;
		}
		public void setCheckBox(Boolean setterCheckBox){
			this.CheckBox = setterCheckBox;
		}
		public Global_Input__c getGI(){
			return this.GI;
		}
		public void setCheckBoxB(Global_Input__c setterGI){
			this.GI = setterGI;
		}
	}
    
	
	private String Year;
	private String LOB;
	private String Segment;
	private List<GlobalInputs> GlobalInput_List = new List<GlobalInputs>(); 
	public void setYear(String setterYear){
		this.Year = setterYear;
	}
	public String getYear(){
		return this.Year;
	}
	public void setLOB(String setterLOB){
		this.LOB = setterLOB;
	}
	public String getLOB(){
		return this.LOB;
	}
	public void setSegment(String setterSegment){
		this.Segment = setterSegment;
	}
	public String getSegment(){
		return this.Segment;
	}
	public void setGlobalInput_List(List<GlobalInputs> setterList){
		GlobalInput_List.addAll(setterList);
	}
	public List<GlobalInputs> getGlobalInput_List(){
		return this.GlobalInput_List;
	}
	public List<SelectOption> getGI_Years(){
		List<SelectOption> options = new List<SelectOption>();
		options.add(new SelectOption('None','-None-'));
		options.add(new SelectOption('2010','2010'));
		options.add(new SelectOption('2011','2011'));
		return options;
	}
	public List<SelectOption> getGI_LOB(){
		List<SelectOption> options = new List<SelectOption>();
		options.add(new SelectOption('None','-None-'));
		options.add(new SelectOption('CL','CL'));
		options.add(new SelectOption('PL','PL'));
		options.add(new SelectOption('LAU','LAU'));
		options.add(new SelectOption('Summit','Summit'));
		return options;
	}
	public List<SelectOption> getGI_Segments(){
		List<SelectOption> options = new List<SelectOption>();
		Global_Input__c[] globalInputs = [Select Segment__c, Segment__r.Name from Global_Input__c where OwnerId=: UserInfo.getUserId() and LOB__c='CL'];
		Set<Id> UniqueSegments = new Set<Id>();
		for(Integer i=0;i<globalInputs.size();i++){
			if(!UniqueSegments.contains(globalInputs.get(i).Segment__c)){
				options.add(new SelectOption(globalInputs.get(i).Segment__c,globalInputs.get(i).Segment__r.Name));
				UniqueSegments.add(globalInputs.get(i).Segment__c);
			}
		}
		return options;
	}
	
	public void searchGlobalInputs(){
		GlobalInput_List.clear();
		if(LOB =='CL'){
			Global_Input__c[] globalInputs = [Select Id, Year__c, Segment__r.Name, Name, Retention__c, Rate__c, Exposure__c, Premium_Growth__c, PIF__c, Avg_NB_Premium__c, Iss2Quote__c, Quote2Opp__c, Status__c  from Global_Input__c where OwnerId=: UserInfo.getUserId() and LOB__c=: LOB and Year__c =:Year and Segment__c=: Segment];
			GlobalInputs temp = new GlobalInputs();
			for(Integer i=0; i<globalInputs.size();i++){
				temp.GI = globalInputs.get(i);
				GlobalInput_List.add(temp);
			}
		}
		else{
			Global_Input__c[] globalInputs = [Select Id, Year__c, Segment__r.Name, Name, Retention__c, Rate__c, Exposure__c, Premium_Growth__c, PIF__c, Avg_NB_Premium__c, Iss2Quote__c, Quote2Opp__c, Status__c  from Global_Input__c where OwnerId=: UserInfo.getUserId() and LOB__c=: LOB and Year__c =:Year];
			
			for(Integer i=0; i<globalInputs.size();i++){
				GlobalInputs temp = new GlobalInputs();
				temp.CheckBox = false;
				temp.GI = globalInputs.get(i);
				GlobalInput_List.add(temp);
			}
		}
	} 
}